<template>
    <div class="album">
        <div class="album_info">
            <div class="ablum_img" :style="{'background-image': 'url(' + albumCover + ')'}">
                <img :src="picUrl" alt="">
            </div>
            <div class="right">
                <div class="title">
                    <div class="type">专辑</div>
                    <div class="name">{{name}}</div>
                </div>
                <operation :subscribedCount = "subscribedCount" :shareCount = "shareCount" />
                <div class="artists">歌手：{{artists}}</div>
                <div class="publishTime">时间：{{publishTime | timeFormat}}</div>
            </div>
        </div>
        <!--tabbar 切换显示-->
        <div class="tabbar">
            <div class="tabbar_item"
            v-for="(item,index) in tabbarList" :key="index"
            :class="index == tabbarFlag ? 'tabarLight' : ''"
            @click="changeMenu(index)"
            >
                {{item}}
            </div>
        </div>
        <!--歌曲列表-->
        <musicList :songList = songList :playListId = 'playListId' v-if="tabbarFlag==0" />
        <!--歌单评论列表-->
        <playListComment v-if="tabbarFlag==1"/>
        <description v-if="tabbarFlag==2" :description="description" />
    </div>
</template>

<script>
import operation from '../../components/content/playList/operation'
import musicList from '../../components/content/playList/musicList'
import playListComment from '../../components/content/playList/playListComment'
import description from '../../components/content/playList/description'
import {dateFomat,dtFormat} from '../../util/tool'
import {_getAlbum,_getAlbumDynamic} from '../../network/detail'
export default {
    name: 'album',
    props: [

    ],
    data() {
        return {
            albumCover:require('../../assets/img/coverall.png'),
            name:null,
            picUrl:null,
            type:null,
            artists:null,
            subscribedCount:null,
            shareCount:null,
            publishTime:null,
            tabbarList:['歌曲列表','评论','专辑详情'],
            tabbarFlag:0,
            playListId:0,
            songList:[],
            description:null,
        };
    },
    computed: {

    },
    created() {
        console.log(this.$route.query.id)
        // 或许专辑内容
        _getAlbum(this.$route.query.id)
        .then(res =>{
            console.log(res.data.album.artists[0].name)
            let {name,type,picUrl,publishTime} = res.data.album
            this.artists = res.data.album.artists[0].name
            this.name = name
            this.type = type
            this.picUrl = picUrl
            this.publishTime = publishTime
            this.description = res.data.album.description
            res.data.songs.forEach((val,index) => {
                res.data.songs[index].dt = dtFormat(val.dt)
                this.songList.push(val)
            })
        })
        // 专辑动态信息
        _getAlbumDynamic(this.$route.query.id)
        .then(res => {
            console.log(res.data)
            this.tabbarList[1] = '评论' +  "(" +res.data.commentCount + ")"
            this.subscribedCount = res.data.subCount
            this.shareCount = res.data.shareCount
        })

    },
    mounted() {

    },
    watch: {

    },
    methods: {
        changeMenu(index){
            this.tabbarFlag = index
        },

    },
    filters:{
        timeFormat(el){
            return dateFomat(el)
        }
    },
    components: {
        operation,
        musicList,
        playListComment,
        description
    },
};
</script>

<style scoped lang="less">
@itemecolor:#E03F40;
@infoColor:#ccc;
@more:#666666;
@textColor:#fff;
@title:20px;
.position_flex(@jc:space-between,@ai:center){
  display: flex;
  align-items: @ai;
  justify-content: @jc;
}
.album{
    width: 100%;
    height: calc(100vh - 49px * 2);
    background-color: #2f3640;
    overflow: auto;
    color: @textColor;
    .album_info{
        .position_flex(flex-start,top);
        font-size: 16px;
        margin-top: 30px;
        height: auto; 
        &>div{
            margin-left: 25px;
        }
        .ablum_img{
            width: 240px;
            height: 200px;
            background-repeat: no-repeat;
            background-position: 20px -980px;
            img{
                width: 200px;
                height: 200px;
                border: 1px solid #40739e;
            }
        }
        .right{
            &>div{
                margin-bottom: 30px
            }
            .title{
                .position_flex(flex-start);
                .type{
                    font-size: 14px;
                    padding: 5px;
                    color: @itemecolor;
                    border: 1px solid @itemecolor
                };
                .name{
                    font-size: 24px;
                    position: relative;
                    margin-left: 10px;
                
                }
            }
            
        }
    }
    .tabbar{
        .position_flex(flex-start);
        border-bottom: 1px solid;
        
        margin-top: 40px;
        .tabbar_item{
            margin-left: 50px;
            padding: 20px 0;
            cursor: pointer;
            box-sizing: border-box;
            border-bottom: 5px solid transparent;
        }
        .tabarLight{
            border-bottom: 5px solid @itemecolor;
        }
    }
}
</style>
